FROM node:16-alpine

ARG NODE_ENV=production

WORKDIR /app

COPY package*.json ./

#RUN apk add --no-cache --virtual build-pack git \
 #   && npm install \
 #   && apk del build-pack \
 #   && apk add --no-cache dumb-init
RUN npm -g install pm2;
ARG RUNTIME_USER=mercury
RUN adduser -D ${RUNTIME_USER}
RUN mkdir -p /home/${RUNTIME_USER}; \
    chown ${RUNTIME_USER}:${RUNTIME_USER} /home/${RUNTIME_USER}; \
	chown ${RUNTIME_USER}:${RUNTIME_USER} /app
RUN npm i
COPY . .

#EXPOSE 3000

#ENTRYPOINT ["dumb-init", "--"]

CMD ["pm2-runtime", "start", "pm2.json"]
